<template>
  <div id="news">
    <div class="banner">
      <el-image style="width: 100%;position: relative;top:-4px;" :src="url" fit="fit"></el-image>
    </div>
    <el-row>
      <el-col :span="3">
        <div class="grid-content bg-purple"></div>
      </el-col>
      <el-col :span="18">
        <div>
          <div class="news_content">
            <div class="item" v-for="news in newsList" :key="news.newsId" @click="goNewsDetail(news.newsId)">
              <el-image style="width:284px;height:150px;"
                        :src="news.coverUrl"
                        fit="fit">
              </el-image>
              <div class="text">
                <div class="title">{{ news.newsTitle }}</div>
                <div class="text_content">
                  {{news.newsContent}}
                </div>
                <div class="date"><span>{{ news.adminName }} </span>· 发布日期 <span class="time">{{news.createTime}}</span></div>
              </div>
            </div>
            <el-pagination
                background
                layout="prev, pager, next"
                :total="total"
                align="center"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-size="pageSize"
                :hide-on-single-page="value"
                style="padding-top: 15px"
            >
            </el-pagination>
          </div>
        </div>
      </el-col>
      <el-col :span="3">
        <div class="grid-content bg-purple"></div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import news from '@/assets/img/news.png'
import {getNewsList} from "@/network/recruit";
export default {
  name: "News",
  components:{
  },
  data() {
    return {
      url: news,
      value: true,
      currentPage: 1,
      total: 1000,
      pageSize: 30,
      newsList:[],
    }
  },
  mounted() {
    this.NewsList();
  },
  methods: {
    handleCurrentChange(currentPage) {
      this.currentPage = currentPage;
    },
    goNewsDetail(newsId){
      this.$router.push({name:'newsDetail',params:{newsId:newsId}});
    },
    NewsList(){
      getNewsList(this.currentPage,this.pageSize).then(res=>{
        this.newsList = res.data.data.list;
        this.total = res.data.data.total;
      })
    }
  },
}
</script>

<style scoped>
.banner {
  height: 213px;
}

.grid-content {
  min-height: 50px;
  font-size: 14px;
}

.news_content {
  padding: 25px 100px;
  background: #fff;
  margin-top: 15px;
}

.item {
  padding: 35px 0;
  border-bottom: 1px #ededed solid;
  cursor: pointer;
}

.text {
  display: inline-block;
  width: 610px;
  float: right;
}

.title {
  text-align: left;
  font-size: 20px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text_content {
  height: 75px;
  line-height: 25px;
  color: #666;
  padding: 20px 0 0;
  margin-bottom: 15px;
  overflow: hidden;
}

.date {
  color: #999;
  line-height: 18px;
  font-size: 14px;
}
</style>